package com.yn.pet.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.filter.OncePerRequestFilter;

@Configuration
public class AppTokenFilterConfig {

    @Bean
    public FilterRegistrationBean<OncePerRequestFilter> appTokenFilterRegistration() {
        FilterRegistrationBean<OncePerRequestFilter> registration = new FilterRegistrationBean<>();
        AppTokenFilter appTokenFilter = new AppTokenFilter();
        registration.setFilter(appTokenFilter);
        registration.addUrlPatterns("/front/*"); // 设置拦截路径
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE); // 设置过滤器优先级
        return registration;
    }
}